﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace PwdMgrUI.Utils
{
    public static class PasswordBoxHelper
    {
        #region Password
        public static readonly DependencyProperty PasswordProperty =
            DependencyProperty.RegisterAttached(
            "Password",
            typeof(string),
            typeof(PasswordBoxHelper),
            new PropertyMetadata(new PropertyChangedCallback(OnPasswordChanged))
            );

        public static void SetPassword(DependencyObject d, string value)
        {
            d.SetValue(PasswordProperty, value);
        }

        public static string GetPassword(DependencyObject d)
        {
            return (string)d.GetValue(PasswordProperty);
        }

        private static void OnPasswordChanged(DependencyObject d, 
            DependencyPropertyChangedEventArgs e)
        {
            PasswordBox box = (PasswordBox)d;

            box.Password = (string)e.NewValue;
        }
        #endregion

        #region IsEnable

        #endregion
    }
}
